import { request } from "@/utils/service"
import type { SysRole } from "./type/user"

export const roleAllApi = () => {
  return request<ApiResponseData<SysRole[]>>({
    url: "admin/role/all",
    method: "post",
    data: {
      mode: "all"
    }
  })
}

export const roleAddApi = (data: { userRole: SysRole }) => {
  return request<ApiResponseData<string>>({
    url: "admin/role/insert",
    method: "post",
    data
  })
}

export const roleUpdateApi = (role: SysRole) => {
  return request<ApiResponseData<string>>({
    url: "admin/role/update",
    method: "post",
    data: {
      accept: role
    }
  })
}

export const roleDelApi = (ids: string[]) => {
  return request<ApiResponseData<string>>({
    url: "admin/role/del/id",
    method: "post",
    data: ids
  })
}

export const rolePageApi = (data: PageParams<SysRole>) => {
  return request<ApiResponseData<PageResult<SysRole>>>({
    url: "admin/role/page",
    method: "post",
    data
  })
}
